package com.ruoyi.module.promotionrecord.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.promotionrecord.domain.BizPromotionRecord;
import com.ruoyi.module.promotionrecord.service.IBizPromotionRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推广记录Controller
 * 
 * @author zhaoxi
 * @date 2023-09-08
 */
@RestController
@RequestMapping("/module/promotionrecord")
public class BizPromotionRecordController extends BaseController
{
    @Autowired
    private IBizPromotionRecordService bizPromotionRecordService;

    /**
     * 查询推广记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:promotionrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizPromotionRecord bizPromotionRecord)
    {
        startPage();
        List<BizPromotionRecord> list = bizPromotionRecordService.selectBizPromotionRecordList(bizPromotionRecord);
        return getDataTable(list);
    }

    /**
     * 导出推广记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:promotionrecord:export')")
    @Log(title = "推广记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizPromotionRecord bizPromotionRecord)
    {
        List<BizPromotionRecord> list = bizPromotionRecordService.selectBizPromotionRecordList(bizPromotionRecord);
        ExcelUtil<BizPromotionRecord> util = new ExcelUtil<BizPromotionRecord>(BizPromotionRecord.class);
        return util.exportExcel(list, "推广记录数据");
    }

    /**
     * 获取推广记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:promotionrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizPromotionRecordService.selectBizPromotionRecordById(id));
    }

    /**
     * 新增推广记录
     */
    @PreAuthorize("@ss.hasPermi('module:promotionrecord:add')")
    @Log(title = "推广记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizPromotionRecord bizPromotionRecord)
    {
        return toAjax(bizPromotionRecordService.insertBizPromotionRecord(bizPromotionRecord));
    }

    /**
     * 修改推广记录
     */
    @PreAuthorize("@ss.hasPermi('module:promotionrecord:edit')")
    @Log(title = "推广记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizPromotionRecord bizPromotionRecord)
    {
        return toAjax(bizPromotionRecordService.updateBizPromotionRecord(bizPromotionRecord));
    }

    /**
     * 删除推广记录
     */
    @PreAuthorize("@ss.hasPermi('module:promotionrecord:remove')")
    @Log(title = "推广记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizPromotionRecordService.deleteBizPromotionRecordByIds(ids));
    }
}
